package com.bootdo.lvyou_specialty.dao;

import com.bootdo.lvyou_specialty.domain.LvyouSpecialtyOrderContent;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 
 * @author haojiangbo
 * @email 2100272728@qq.com
 * @date 2019-10-14 09:58:32
 */
@Mapper
public interface LvyouSpecialtyOrderContentDao {

	LvyouSpecialtyOrderContent get(Long id);
	
	List<LvyouSpecialtyOrderContent> list(Map<String,Object> map);

	List<String> listGroup(Map<String,Object> map);

	List<LvyouSpecialtyOrderContent> listGroupList(@Param("list") List<String> list);
	
	int count(Map<String,Object> map);

	List<Integer> merchantCount(Map<String,Object> map);
	
	int save(LvyouSpecialtyOrderContent lvyouSpecialtyOrderContent);
	
	int update(LvyouSpecialtyOrderContent lvyouSpecialtyOrderContent);
	
	int remove(Long id);
	
	int batchRemove(Long[] ids);

	@Select("select * from me_lvyou_specialty_order_content where goods_order_no = #{orderNo}")
	List<LvyouSpecialtyOrderContent> getByOrderNo(@Param("orderNo") String orderNo);

	@Select("select * from me_lvyou_specialty_order_content where merchant_order_no = #{merchantOrderNo}")
	List<LvyouSpecialtyOrderContent> getByMerchantOrderNo(@Param("merchantOrderNo") String merchantOrderNo);

	@Select("select * from me_lvyou_specialty_order_content where tk_order_no = #{tkOrderNo}")
	List<LvyouSpecialtyOrderContent> getByTkOrderNo(@Param("tkOrderNo") String tkOrderNo);

	@Select("select * from me_lvyou_specialty_order_content where goods_order_no = #{orderNo} and merchant_id = #{merchantId}")
	List<LvyouSpecialtyOrderContent> getByOrderNoAndMerchant(@Param("orderNo") String orderNo, @Param("merchantId")Long merchantId);

	@Update("update me_lvyou_specialty_order_content set `status` = 2, wx_order_no = #{wxOrderNo}  where goods_order_no = #{orderNo}")
	int updateStatus(@Param("orderNo") String orderNo, @Param("wxOrderNo")String wxOrderNo);

	@Update("update me_lvyou_specialty_order_content set `status` = 3,logistics_type = #{logisticsType},logistics_number = #{logisticsNumber} where merchant_order_no = #{orderNo} and status = 2")
	int editDelivery(@Param("orderNo") String orderNo, @Param("logisticsType") String logisticsType, @Param("logisticsNumber") String logisticsNumber);

	@Update("update me_lvyou_specialty_order_content set `status` = #{status} where merchant_order_no = #{merchantOrder}")
	int changeStatus(@Param("merchantOrder") String merchantOrder, @Param("status") Integer status);


	@Update("update me_lvyou_specialty_order_content set `status` = 4,tk_order_no = #{tkOrderNo}  where merchant_order_no = #{merchantOrderNo}")
	int tkPre(@Param("merchantOrderNo")String merhcantOrderNo, @Param("tkOrderNo")String tkOrderNo);

	@Update("update me_lvyou_specialty_order_content set `status` = #{status}, tk_wx_order_no = #{tkWxOrderNo} where tk_order_no = #{tkOrderNo}")
	int tkWxCallBack(@Param("tkOrderNo")String tkOrderNo, @Param("tkWxOrderNo")String tkWxOrderNo, @Param("status")Integer status);

	@Update("update me_lvyou_specialty_order_content set `status` = #{status}, tk_order_no = #{tkOrderNo} where merchant_order_no = #{merchantOrderNo}")
	int tkOrderNo(@Param("merchantOrderNo") String merchantOrderNo, @Param("tkOrderNo") String tkOrderNo, @Param("status") Integer status);

	@Update("update me_lvyou_specialty_order_content set `status` = #{status} where merchant_order_no = #{merchantOrder} and status = 2")
	int createTuikuan(@Param("merchantOrder")String merchantOrder, @Param("status") Integer status);


}
